Skip to content

test(arch): Add unit tests for arch package - #2703

Closed
adity1raut wants to merge 3 commits into
unikraft:stagingfrom
adity1raut:unikraft/arch/arch_test.go
Closed

adity1raut wants to merge 3 commits into
unikraft:stagingfrom
adity1raut:unikraft/arch/arch_test.go

Conversation

@adity1raut

@adity1raut adity1raut commented Mar 9, 2026 •

Copy link
Copy Markdown

Prerequisite checklist

Description of changes

Summary

  • Adds comprehensive unit tests for unikraft/arch package
  • Achieves 97% coverage (100% on all files except platform-specific host.go)

Functions tested

  • ArchitectureName.String, ArchitectureByName, ArchitecturesByName
  • Architectures, ArchitectureAliases
  • NewArchitectureFromSchema — empty string error + valid name
  • All ArchitectureConfig accessors: Name, String, Source, Version, Type, Path
  • IsUnpacked — existing dir, non-existent path, empty path
  • KConfig — correct CONFIG_ARCH_* key for x86_64, arm64, arm, unknown
  • MarshalYAML, KConfigTree, PrintInfo
  • TransformFromSchema — string, invalid type, with UK_BASE context
  • HostArchitecture — current host arch
  • All options: WithName, WithVersion, WithSource, WithPath, WithKConfig

Note

host.go reaches 60% coverage — the arm/default branches of
HostArchitecture are platform-specific and cannot be tested on amd64.

Related Issue

Closes #2702

Test plan

  • Run go test kraftkit.sh/unikraft/arch -cover — 97% coverage, all PASS

adity1raut added 2 commits March 9, 2026 19:59
Signed-off-by: adity1raut <araut7798@gmail.com>
…verage

Signed-off-by: adity1raut <araut7798@gmail.com>

@craciunoiuc craciunoiuc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good here. Thanks!

Reviewed-by: Cezar Craciunoiu cezar.craciunoiu@unikraft.com
Approved-by: Cezar Craciunoiu cezar.craciunoiu@unikraft.com

Signed-off-by: adity1raut <araut7798@gmail.com>

@nderjung nderjung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see our contributing guidelines for code and commit conventions.

@adity1raut

Copy link
Copy Markdown
Author

Please see our contributing guidelines for code and commit conventions.

I read once again, sorry for that

@nderjung nderjung closed this Mar 9, 2026
@github-project-automation github-project-automation Bot moved this from 🧊 Icebox to 🚀 Done in KraftKit Roadmap Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚀 Done

Development

Successfully merging this pull request may close these issues.

test(arch): add unit tests for unikraft/arch package to achieve 100% coverage

3 participants